package com.shengyin.ec.model.entity;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

/**
 */
@Entity
@Table(name="Resources")
public class Resources extends BaseEntity implements java.io.Serializable {

	// Fields

	private String url;
	private Integer priority;
	private Integer type;
	private String name;
	private String memo;
	
	@ManyToMany(mappedBy="resources",fetch=FetchType.EAGER)
	private Set<Roles> roles = new HashSet<Roles>(0);
	
	// Constructors

	/** default constructor */
	public Resources() {
	}
	
	
	public Set<Roles> getRoles() {
		return roles;
	}


	public void setRoles(Set<Roles> roles) {
		this.roles = roles;
	}


	public String getMemo() {
		return memo;
	}



	public void setMemo(String memo) {
		this.memo = memo;
	}




	public String getUrl() {
		return this.url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public Integer getPriority() {
		return this.priority;
	}

	public void setPriority(Integer priority) {
		this.priority = priority;
	}

	public Integer getType() {
		return this.type;
	}

	public void setType(Integer type) {
		this.type = type;
	}

	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}


	public Object[] getRolenames() {
		ArrayList<String> rolenames=new ArrayList<String>();
		for(Roles role:roles){
			rolenames.add(role.getName());
		}
		return rolenames.toArray();
	}





}